package chainofResponsibilityPattern.handler.client;

import chainofResponsibilityPattern.handler.handler.PriceHandler;

import java.util.Random;

/**
 * Created by JiaJia on 2019/6/17 0017.
 */
public class Customer {
    private PriceHandler priceHandler;

    public void setPriceHandler(PriceHandler priceHandler) {
        this.priceHandler = priceHandler;
    }

    public void requestDiscount(float discount){
        priceHandler.processDiscount(discount);
    }

    public static void main(String[] args) {
        Customer customer=new Customer();
        customer.setPriceHandler(PriceHandler.creatPriceHandler());

        Random rand=new Random();
        for (int i = 1; i <100; i++) {
            System.out.print(i+":");
            customer.requestDiscount(rand.nextFloat());
        }
    }
}